﻿import QtQuick 2.0
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.12
Rectangle{
    width: 581
    height: 554
    signal loginSignal()
    color: "#1F2A37"
    Image{
        x: 210
        y: 0
        source: "qrc:/imgs/xg_icon.png"
    }

    Image{ 
        x: 146
        y: 50
        source: "qrc:/imgs/title_icon.png"
    }

    Rectangle{
        x: 0
        y: 168
        width: 581
        height: 86
        radius: 8
        color: Qt.rgba(255, 255, 255, 0.1)
        border.width: 0

        Image{
            id: userIcon
            anchors.left: parent.left
            anchors.leftMargin: 34
            anchors.verticalCenter: parent.verticalCenter
            source: "qrc:/imgs/user_icon.png"

        }

        TextField {
            id: user
            width: 300
            height: parent.height
            anchors.left: userIcon.left
            anchors.leftMargin: 54
            anchors.verticalCenter: parent.verticalCenter
            color: "white"
            font{
                family: "Microsoft YaHei"
                pixelSize: 30
            }
            background: Rectangle{
                border.width: 0
                opacity: 0
            }
            text: "admin"
        }
    }

    Rectangle{
        x: 0
        y: 302
        width: 581
        height: 86
        radius: 8
        color: Qt.rgba(255, 255, 255, 0.1)
        border.width: 0

        Image{
            id: passwordIcon
            anchors.left: parent.left
            anchors.leftMargin: 34
            anchors.verticalCenter: parent.verticalCenter
            source: "qrc:/imgs/password_icon.png"

        }

        TextField {
            id: password
            width: 300
            height: parent.height
            anchors.left: passwordIcon.left
            anchors.leftMargin: 54
            anchors.verticalCenter: parent.verticalCenter
            color: "white"
            echoMode: TextInput.Password
            font{
                family: "Microsoft YaHei"
                pixelSize: 30
            }
            background: Rectangle{
                border.width: 0
                opacity: 0
            }
            text: "admin"
        }
    }

    Rectangle{
        id: loginBtn
        x: 0
        y: 468
        width: 581
        height: 108
        radius: 8
        color: "dodgerblue"
        layer.enabled: true
        layer.effect: DropShadow {
            horizontalOffset: 5
            verticalOffset: 5
            radius: 10
            color: "#F0000000"  // 半透明黑色
        }
        Text{
            anchors.centerIn: parent
            text: "登录"
            color: "white"
            font{
                family: "Microsoft YaHei"
                pixelSize: 36
            }
        }
        MouseArea{
            anchors.fill: parent
            onClicked: {
                if(user.text === "admin" && password.text === "admin"){
                    loginErrorRect.visible = false
                    loginSignal()  //发送登录信号
                }
                else{
                    loginErrorRect.visible = true
                }
            }
        }
    }

    Rectangle{
        id: loginErrorRect
        visible: false
        anchors.top: loginBtn.bottom
        anchors.topMargin: 40
        anchors.horizontalCenter: parent.horizontalCenter
        color: "#F9CCCC"
        border.width: 0
        radius: 2
        width: 250
        height: 50
        Text{
            anchors.centerIn: parent
            text: "账户或密码有误"
            color: "white"
            font{
                family: "Microsoft YaHei"
                pixelSize: 22
            }
        }
    }
}
